package com.rgs.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.rgs.ssm.dao.IOrderDao;
import com.rgs.ssm.domain.Orders;
import com.rgs.ssm.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @create 2021-02-17 14:34
 **/

@Service
@Transactional
public class OrderService implements IOrderService {

    @Autowired
    private IOrderDao orderDao;

    @Override
    public void saveOrders(Orders order) {
        orderDao.saveOrders(order);
    }

    @Override
    public void delete(Integer id) {
        orderDao.delete(id);
    }

    @Override
    public void update(Orders order) {
        orderDao.update(order);
    }

    /**
     * 使用PageHelper插件进行分页
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<Orders> findAll(int page,int size){
        PageHelper.startPage(page,size);
        return orderDao.findAll();
    }

    @Override
    public Orders findById(Integer id) {
        return orderDao.findById(id);
    }

}
